package com.ewanghuiju.app.widget.popupwindow;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.ewanghuiju.app.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 公共的提示信息弹框
 * @time 2020/2/19
 */
public class CustomTipPopup extends BasePopupWindow {

    @BindView(R.id.tv_popup_title)
    TextView tvPopupTitle;
    @BindView(R.id.tv_popup_content)
    TextView tvPopupContent;
    private PopupItemClickCallback popupItemClickCallback;

    public CustomTipPopup(Context context, String title, String content, PopupItemClickCallback popupItemClickCallback) {
        super(context);
        ButterKnife.bind(this, getContentView());
        tvPopupTitle.setText(TextUtils.isEmpty(title) ? "" : title);
        tvPopupContent.setText(TextUtils.isEmpty(content) ? "" : content);
        this.popupItemClickCallback = popupItemClickCallback;
    }

    /**
     * 设置文本
     *
     * @param title
     * @param content
     */
    public void setPopupText(String title, String content) {
        if (tvPopupTitle != null)
            tvPopupTitle.setText(TextUtils.isEmpty(title) ? "" : title);
        if (tvPopupContent != null)
            tvPopupContent.setText(TextUtils.isEmpty(content) ? "" : content);
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popup_custom_tip);
    }

    @OnClick({R.id.tv_sure})
    public void doClick(View view) {
        int id = view.getId();
        switch (id) {
            case R.id.tv_sure:
                //确定按钮
                dismiss();
                break;
            default:
                break;
        }
    }
}
